package com.itheima.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@RestController
/**
 * @RestController = @Controller + @ResponseBody
 */
@RequestMapping("/user")
public class UserController {

    @GetMapping("/{userId}")
    /**
     * @RequestMapping(method = RequestMethod.GET)
     * @PathVariable 将userId的值赋给参数id
     */
    public String findById(@PathVariable("userId") Integer id){
        System.out.println("testGet:" + id);
        return "success";
    }

    @PostMapping("")
    /**
     * @RequestMapping(method = RequestMethod.POST)
     */
    public String save(){
        System.out.println("test post");
        return  "success";
    }

    @PutMapping("")
    /**
     * @RequestMapping(method = RequestMethod.PUT)
     */
    public String update(){
        System.out.println("test put ");
        return  "success";
    }

    @DeleteMapping("/{id}")
    /**
     * @RequestMapping(method = RequestMethod.DELETE)
     */
    public String delById(@PathVariable Integer id){
        System.out.println("test delete: " + id);
        return  "success";
    }
}
